/*==============================================================*/
/* DBMS name:      Microsoft SQL Server 2012                    */
/* Created on:     2021/10/26 9:46:32                           */
/*==============================================================*/


if exists (select 1
            from  sysobjects
           where  id = object_id('UserInfo')
            and   type = 'U')
   drop table UserInfo
go

if exists (select 1
            from  sysobjects
           where  id = object_id('application')
            and   type = 'U')
   drop table application
go

if exists (select 1
            from  sysobjects
           where  id = object_id('department')
            and   type = 'U')
   drop table department
go

if exists (select 1
            from  sysobjects
           where  id = object_id('employee')
            and   type = 'U')
   drop table employee
go

/*==============================================================*/
/* Table: UserInfo                                              */
/*==============================================================*/
create table UserInfo (
   uid                  int                  identity,
   uname                nvarchar(80)         null,
   card                 nvarchar(80)         null,
   phone                nvarchar(80)         null,
   adress               nvarchar(80)         null,
   constraint PK_USERINFO primary key (uid)
)
go

/*==============================================================*/
/* Table: application                                           */
/*==============================================================*/
create table application (
   aid                  int                  identity,
   uid                  int                  null,
   session              datetime             null,
   daycount             int                  null,
   peoplesum            int                  null,
   adress               nvarchar(80)         null,
   budget               nvarchar(80)         null,
   accept               nvarchar(80)         null,
   constraint PK_APPLICATION primary key (aid)
)
go

/*==============================================================*/
/* Table: department                                            */
/*==============================================================*/
create table department (
   depid                int                  identity,
   dename               nvarchar(80)         null,
   charge               nvarchar(80)         null,
   phone                bigint               null,
   email                nvarchar(80)         null,
   constraint PK_DEPARTMENT primary key (depid),
   constraint AK_U_CHARGE_DEPARTME unique (charge)
)
go

/*==============================================================*/
/* Table: employee                                              */
/*==============================================================*/
create table employee (
   eid                  int                  identity,
   ename                nvarchar(80)         null,
   job                  nvarchar(80)         null,
   phone                nvarchar(80)         null,
   salary               money                null,
   constraint PK_EMPLOYEE primary key (eid)
)
go

